package com.hkg.springcloud.controller;

import com.hkg.springcloud.config.ApplicationConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @ClassName : OrderControler
 * @Author : 坏老爷
 * @Date: 2020-03-31 13:48
 */
@RestController
@Slf4j
public class OrderController {
    @Value("${service-url.nacos-user-service}")
    private String PAYMENT_URL;
    @Resource
    private ApplicationConfig applicationConfig;

    @RequestMapping("/consumer/payment/get/{id}")
    public String get(@PathVariable("id") Long id) {
        RestTemplate restTemplate = applicationConfig.getRestTemplate();
        return restTemplate.getForObject(PAYMENT_URL + "/payment/nacos/" + id, String.class);
    }
}
